﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace ftpd_console
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.Default;
            Console.WriteLine(Console.OutputEncoding.EncodingName);
            FTP_Accepter accepter = new FTP_Accepter("127.0.0.1", 22);
            Console.ReadLine();
            accepter.Close();
            FTP_Listener.CloseAll();
            Console.WriteLine("Press Enter to exit... [ENTER]");
            Console.ReadLine();
            
            //подключение
            //try
            //{
            //    byte[] byData;
            //    byte[] byReceived = new byte[1024];
            //    int bytes;
            //    string page;

            //    IPEndPoint ipe = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 21);
            //    Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
            //    server.Connect(ipe);

            //    //Получаем приветствие от сервера
            //    bytes = server.Receive(byReceived, byReceived.Length, 0);
            //    page = Encoding.ASCII.GetString(byReceived, 0, bytes);

            //    Console.WriteLine("Server :: " + page);

            //    //Посылаем логин
            //    byData = System.Text.Encoding.ASCII.GetBytes("USER jeronima\r\n");
            //    server.Send(byData, byData.Length, 0);

            //    //Получаем ответ
            //    bytes = server.Receive(byReceived, byReceived.Length, 0);
            //    page = Encoding.ASCII.GetString(byReceived, 0, bytes);

            //    Console.WriteLine("Server :: " + page);

            //    //Посылаем пароль
            //    byData = System.Text.Encoding.ASCII.GetBytes("PASS 128256\r\n");
            //    server.Send(byData);

            //    //Получаем ответ
            //    bytes = server.Receive(byReceived, byReceived.Length, 0);
            //    page = Encoding.ASCII.GetString(byReceived, 0, bytes);

            //    Console.WriteLine("Server :: " + page);
            //    Console.ReadLine();
            //}
            //catch (Exception e)
            //{
            //    Console.WriteLine(e.StackTrace);
            //}
        }
    }
}
